﻿#ifndef FPCACHEDBLOADER_H
#define FPCACHEDBLOADER_H

#include <QObject>
#include <QList>
#include <QString>
#include <QMap>
#include <QSql>
#include <QSqlDatabase>

namespace ZKFP
{
class FingerprintCacheDB;
/**
 * @brief The FPCacheDBLoader class 辅助类，用于加载指纹数据库。
 */
class FPCacheDBLoader : public QObject
{
    Q_OBJECT
public:
    explicit FPCacheDBLoader(QObject *parent = nullptr);
    /**
     * @brief loadFromFile 从文件中加载指纹数据库，并将指纹数据送到 db
     * @param fileName 保存指纹数据的文件
     * @param db
     * @return true 表示成功， false 表示失败
     */
    bool loadFromFile(QString fileName, FingerprintCacheDB *fpDB);
    void initFPCacheDB(FingerprintCacheDB *fpDB);
    QList<int> userIDs();
    QString userName(int userID);
    QMap<int, QString> userNames();
    bool userInfo(int userID, QString &name, QString &password, QByteArray &fpTemplate);
    bool addUser(int userID, QString name, QString password, QByteArray fpTemplate);
    bool deleteUser(int userID);
signals:

public slots:

private:
    QSqlDatabase m_database;
};

}

#endif // FPCACHEDBLOADER_H
